#include<stdio.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include<errno.h>
#define LOG_NORMAL "logNormal.txt"
#define LOG_ERROR "logError.txt"
#define LOG "log.txt"
int main()
{
    int fd=open(LOG_NORMAL,O_CREAT|O_WRONLY|O_APPEND,0666);
    if(fd<0)
    {
        perror("open");
        return 1;
    }

    dup2(fd,1);
    printf("hello zhenbailinzi\n");
    close(fd);
    //close(1);
    //open(LOG_NORMAL,O_WRONLY|O_CREAT|O_APPEND,0666);
    //close(2);
    //open(LOG_ERROR,O_WRONLY|O_CREAT|O_APPEND,0666);
    //open(LOG,O_WRONLY|O_CREAT|O_APPEND,0666);
    //printf("hello printf->stdout\n");
    //printf("hello printf->stdout\n");
    //fprintf(stdout,"hello fprintf->stdout\n");
    //fprintf(stderr,"hello fprintf->stderr\n");
//    printf("%d\n",stdin->_fileno);
//    printf("%d\n",stdout->_fileno);
//    printf("%d\n",stderr->_fileno);
//    FILE*fp=fopen(LOG,"w");
//
//    printf("%d\n",fp->_fileno);
//    return 0;
    //fclose(stdin);
    //int fd1=open(LOG,O_WRONLY);
    //int fd2=open(LOG,O_WRONLY);
    //printf("%d\n",fd1);
    //printf("%d\n",fd2);
    //close(1);
    ////输出重定向
    ////int fd=open(LOG,O_WRONLY|O_CREAT|O_TRUNC,0666);
    ////追加重定向
    //int fd=open(LOG,O_WRONLY|O_CREAT|O_APPEND,0666);

    //printf("you can see me\n");
    //printf("you can see me\n");
    //printf("you can see me\n");
    //printf("you can see me\n");
    //close(0);
    //int fd=open(LOG,O_RDONLY);
    //int m,n;
    //scanf("%d %d",&m,&n);
    //printf("m=%d,n=%d\n",m,n);
}
